package com.xyq.friend.controller.user;

import com.xyq.common.core.constants.HttpConstants;
import com.xyq.common.core.controller.BaseController;
import com.xyq.common.core.domain.Result;
import com.xyq.common.core.domain.TableDataInfo;
import com.xyq.friend.aspect.CheckStatus;
import com.xyq.friend.domain.exam.dto.ExamDTO;
import com.xyq.friend.domain.exam.dto.ExamQueryDTO;
import com.xyq.friend.service.user.UserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {
    @Autowired
    private UserExamService  userExamService ;
    //报名竞赛: 有token 和 examId
    @CheckStatus

    @PostMapping("/enter")
    public Result enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token ,@RequestBody @Validated ExamDTO examDTO){
        return  toResult(userExamService.enter(token , examDTO)) ;
    }

    @CheckStatus

    @GetMapping("/redis/list")
    public TableDataInfo redisList(ExamQueryDTO examQueryDTO) {
        //  从redis里获取数据
        return userExamService.redisList(examQueryDTO);
    }
}
